<?php
namespace app\common\model;
use think\Config;
use think\Db;
use think\Model;

class Comment extends Model{

    protected $table = "jiujiu_shop_product_comment";

    public function getProductComment($id,$shopId){

        return Db::table('jiujiu_shop_product_comment')
            ->field(['jiujiu_shop_product_comment.*','jiujiu_user.img as userImg','jiujiu_user.nickname'])
            ->join('jiujiu_user','jiujiu_user.uid=jiujiu_shop_product_comment.uid','LEFT')
            ->where('jiujiu_shop_product_comment.productId',$id)
            ->where('jiujiu_shop_product_comment.shopId',$shopId)
            ->select();
    }


  public function getProductCommentCount($id,$shopId){

        return $this->where('productId',$id)->where('shopId',$shopId)->count();
    }




    public function getProductTypeComment($id,$shopId,$type){

        return $this->where('productId',$id)
            ->where('shopId',$shopId)
            ->where('cType',$type)
            ->select();
    }


    public function getProductTypeCommentCount($id,$shopId,$type){

        return $this->where('productId',$id)
            ->where('shopId',$shopId)
            ->where('cType',$type)
            ->count();
    }



    public function getShopCommentByType($shopId,$type){
        return $this->where('shopId',$shopId)->where('cType',$type)->select();
    }


    public function getShopComment($shopId){
        return $this->where('shopId',$shopId)->select();
    }





}